package io.shuttle.mbe.api

import io.shuttle.mbe.api.annotation.ChromeMinVersion
import io.shuttle.mbe.api.annotation.ChromeOSOnly
import io.shuttle.mbe.api.annotation.PromiseStyleMinVersion
import io.shuttle.mbe.api.types.ArrayBuffer
import io.shuttle.mbe.api.types.Value1Function
import io.shuttle.mbe.core.Promise
////////////////////
// Wallpaper
////////////////////
/**
 * Use the `Browser.wallpaper` API to change the ChromeOS wallpaper.
 *
 * Permissions: "wallpaper"
 * @platform ChromeOS only
 * @since Chrome 43
 */
@ChromeOSOnly
@ChromeMinVersion(43)
abstract class Wallpaper {
    // Sets wallpaper to the image at url or wallpaperData with the specified layout
    // @callback thumbnail - The jpeg encoded wallpaper thumbnail. It is generated by resizing the wallpaper to 128x60.
    @PromiseStyleMinVersion(96)
    abstract fun setWallpaper(details:WallpaperInfo, callback: Value1Function<ArrayBuffer?>? = null): Promise<ArrayBuffer?>
    // The supported wallpaper layouts.
    @ChromeMinVersion(44)
    enum class WallpaperLayout{
        STRETCH,
        CENTER,
        CENTER_CROPPED,
    }

    data class WallpaperInfo(
        // The jpeg or png encoded wallpaper image as an ArrayBuffer.
        var data: ArrayBuffer?,
        // The file name of the saved wallpaper.
        var filename:  String,
        // The supported wallpaper layouts.
        var layout: WallpaperLayout,
        // True if a 128x60 thumbnail should be generated. Layout and ratio are not supported yet.
        var thumbnail: Boolean?,
        // The URL of the wallpaper to be set (can be relative).
        var url: String?,
    )
}